﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BingZi.HY.Core;
using NewLife.Web;
using System.Collections;
using BingZi;
using XCode;

namespace FrameWork.web
{
    public partial class team : BaseTemplatePage
    {
        #region "==方法=="

        /// <summary>
        /// 绑定页面元素
        /// </summary>
        private void BindPageItem()
        {
            Int32 ProductID = WebHelper.GetIntParam(HttpContext.Current.Request, "id", 0);
            if (ProductID > 0)
            {
                app_Product Product = app_Product.FindByKeyForEdit(ProductID);
                if (Product != null && Product.ID > 0)
                {
                    if (Product.Status == (Int32)EnumProductStatus.Published)
                    {
                        NewLife.QueryParam qp = new NewLife.QueryParam();
                        qp.PageSize = 6;
                        
                        if (Product.CategoryID > 0)
                        {
                            qp.Where.Add(new NewLife.SearchParam(app_Product._.CategoryID, Product.CategoryID, NewLife.SearchType.Equal));
                        }
                        qp.Where.Add(new NewLife.SearchParam(app_Product._.ID, Product.ID, NewLife.SearchType.Ne));
                        qp.Where.Add(new NewLife.SearchParam(app_Product._.Status, (int)EnumProductStatus.Published, NewLife.SearchType.Equal));
                        int RecordCount = 0;
                        EntityList<app_Product> ProductList = app_Product.FindAll(qp, out RecordCount);
                        Hashtable puts = new Hashtable();
                        puts.Add("Product", Product);
                        puts.Add("Now", DateTime.Now);
                        puts.Add("ProductList", ProductList);
                        BasePage_Title = Common.leftx( Product.Title,100);

                        Response.Write(ViewTemplate(EnumTemplateFile.team, puts));
                    }
                    else
                    {
                        //商品未上架或者已经删除了
                    }
                }
                else
                {
                    //商品未找到
                }
            }
            else
            {
                //商品未找到
            }
        }

        #endregion



        #region "==事件=="


        /// <summary>
        /// 页面加载
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                //绑定页面元素
                BindPageItem();


            }

        }




        #endregion
    }
}